public class text13 {
    public static void main(String[] args) {
        Object lock1=new Object();
        Object lock2=new Object();
       Thread thread1=new Thread(()->{
           System.out.println("线程1");
           synchronized (lock1)
           {
               lock1.notify();
           }



       });
       Thread thread2=new Thread(()->{
           synchronized (lock1)
           {
               try {
                   lock1.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }

           System.out.println("线程2");
           synchronized (lock2)
           {
               lock2.notify();
           }


       });
       Thread thread3=new Thread(()->{
           synchronized (lock2)
           {
               try {
                   lock2.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }

           System.out.println("线程3");

       });

        thread2.start();
       thread3.start();
        thread1.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

    }
}
